package com.yeban.javase.review.previevew;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * @Desc TODO
 * @Author yeban
 * @Date 2025/10/27
 */
public class SerializableDemo1 {

    public static void main(String[] args) {
        try(ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("src/com/yeban/javase/review/text/user.txt"))){
            User user = new User("张三", 18, "123456");
            oos.writeObject(user);
            oos.flush();
            System.out.println("序列化完成！");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
